package com.car.spdier.service.dao.entity;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang.StringUtils;

import com.comm.cache.entity.PunishmentObj;

public class Punishment implements Serializable {
	private int valueCount = 0;
	private static int needSetValueMax = 10;

	private String resultDate;// 案发时间
	private Date queryDate;// 用户查询时间，用户下载时间
	private String org_code;// 执法机关代码或 行政区划代码
	private String rs_code;// 编号：做为记录重复的判定
	private String space;// 违法地点：
	private String org_name;// 采集机关:
	private String content;// 违法内容：
	private String clause;// 违反条款：
	private String accord;// 处罚依据：
	private String Punishment;// 处罚内容：
	private String PunishmentOther;// 其他措施：
	public boolean isRSDate = false;// 案发时间
	public boolean isOrg_code = false;// 执法机关代码或 行政区划代码
	public boolean isRS_code = false;// 编号：
	public boolean isSpace = false;// 违法地点：
	public boolean isOrg_name = false;// 采集机关:
	public boolean isContent = false;// 违法内容：
	public boolean isClause = false;// 违反条款：
	public boolean isAccord = false;// 处罚依据：
	public boolean isPunishment = false;// 处罚内容：
	public boolean isPunishmentOther = false;// 其他措施：
	
    /**
     *  数据库中字段
     * */
	public static String db_result_dt="result_dt", db_org_code="org_code",
	db_rs_code="rs_code", db_rs_space="rs_space", db_org_name="org_name", db_content="content", 
	db_clause="clause", db_accord="accord", db_Punishment="Punishment", db_PunishmentOther="PunishmentOther";

	/**
	 * 这个对像值全了，就新创建一个对像。
	 * 
	 * @return
	 */
	public boolean isFull() {
		if (valueCount == needSetValueMax) {
			checkAll();
			return true;
		}
		return false;
	}

	/**
	 * 对像装好后，每个boolean 变量恢复到初始状态
	 * 
	 * @return
	 */
	private boolean checkAll() {
		if (isRSDate == false && isOrg_code == false && isRS_code == false
				&& isSpace == false && isOrg_name == false
				&& isContent == false && isClause == false && isAccord == false
				&& isPunishment == false && isPunishmentOther == false) {
			return true;
		}
		System.out.println("数据问题" + toString());
		return false;
	}

	public void setValue(String value) {

		if (isRSDate) {
			setResultDate(value);
			isRSDate = false;
			valueCount = valueCount + 1;
			return;
		}
		if (isOrg_code) {
			setOrg_code(value);
			isOrg_code = false;
			valueCount = valueCount + 1;
			return;
		}
		if (isRS_code) {
			setRs_code(value);
			isRS_code = false;
			valueCount = valueCount + 1;
			return;
		}
		if (isSpace) {
			setSpace(value);
			isSpace = false;
			valueCount = valueCount + 1;
			return;
		}
		if (isOrg_name) {
			setOrg_name(value);
			isOrg_name = false;
			valueCount = valueCount + 1;
			return;
		}
		if (isContent) {
			setContent(value);
			isContent = false;
			return;
		}
		if (isClause) {
			setClause(value);
			isClause = false;
			valueCount = valueCount + 1;
			return;

		}
		if (isAccord) {
			setAccord(value);
			isAccord = false;
			valueCount = valueCount + 1;
			return;
		}
		if (isPunishment) {
			setPunishment(value);
			isPunishment = false;
			valueCount = valueCount + 1;
			return;
		}
		if (isPunishmentOther) {
			setPunishmentOther(value);
			isPunishmentOther = false;
			valueCount = valueCount + 1;
			return;
		}

	}

	private boolean isBlank(String str) {
		if (str == null || str.trim().length() == 0) {
			return true;
		}
		return false;
	}

	public String getResultDate() {
		return resultDate;
	}

	public void setResultDate(String resultDate) {
		this.resultDate = resultDate;
	}

	public Date getQueryDate() {
		return queryDate;
	}

	public void setQueryDate(Date queryDate) {
		this.queryDate = queryDate;
	}

	public String getOrg_code() {
		return org_code;
	}

	public void setOrg_code(String org_code) {
		this.org_code = org_code;
	}

	public String getRs_code() {
		return rs_code;
	}

	public void setRs_code(String rs_code) {
		this.rs_code = rs_code;
	}

	public String getSpace() {
		return space;
	}

	public void setSpace(String space) {
		this.space = space;
	}

	public String getOrg_name() {
		return org_name;
	}

	public void setOrg_name(String org_name) {
		this.org_name = org_name;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getClause() {
		return clause;
	}

	public void setClause(String clause) {
		this.clause = clause;
	}

	public String getAccord() {
		return accord;
	}

	public void setAccord(String accord) {
		this.accord = accord;
	}

	public String getPunishment() {
		return Punishment;
	}

	public void setPunishment(String punishment) {
		Punishment = punishment;
	}

	public String getPunishmentOther() {
		return PunishmentOther;
	}

	public void setPunishmentOther(String punishmentOther) {
		PunishmentOther = punishmentOther;
	}

	public String toString() {
		return " 处罚依据="+this.accord +" 违反条款="+ this.clause + " 违法内容"+this.content + " 执法机关代码="+this.org_code
				+ " 采集机关="+this.org_name +" 处罚内容="+ this.Punishment +" 其他措施="+ this.PunishmentOther
				+ " 用户下载时间="+this.queryDate + " 案发时间="+this.resultDate + " 编号="+this.rs_code + " 违法地点="+this.space
				+ " 对像设置属性数量"+this.valueCount;
	}
	public PunishmentObj toPunishmentObj(){
		PunishmentObj obj=new PunishmentObj(); 
		
		obj.setAccord(accord);
		obj.setClause(clause);
		obj.setContent(content);
		obj.setOrgCode(org_code);
		obj.setOrgName(org_name);
		obj.setPunishment(Punishment);
		obj.setPunishmentOther(PunishmentOther);
		obj.setResultDate(resultDate);
		obj.setRsCode(rs_code);
		obj.setSpace(db_rs_space);
		
		return obj;
	}
}
